﻿# author:高金磊
# datetime:2021/11/11 11:25
import socket
"""
检查网络工具类
"""

def _isNetOK(testserver):
    s = socket.socket()
    s.settimeout(3)
    try:
        status = s.connect_ex(testserver)
        if status == 0:
            s.close()
            return True
        else:
            return False
    except Exception as e:
        return False


def isNetChainOK(testserver=('www.baidu.com', 443)):
    isOK = _isNetOK(testserver)
    return isOK
